import 'package:flutter/material.dart';

class WebViewPage extends StatefulWidget {
  WebViewPage({
    super.key,
    required this.title,
  });
  final String title;
  @override
  _WebViewPageState createState() {
    return _WebViewPageState();
  }
}

class _WebViewPageState extends State<WebViewPage> {
  String? name;
  @override
  void initState() {
    super.initState();
    // 组件初始化完成后获取路由参数
    WidgetsBinding.instance.addPostFrameCallback((_) {
      var map = ModalRoute.of(context)?.settings.arguments;
      if (map is Map) {
        name = map['name'];
        // 需要调方法 刷新值
        setState(() {});
      }
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          // title: Text('WebView Page${widget.title}'),
          title: Text(name ?? ''),
        ),
        body: SafeArea(
          child: Container(
              child: InkWell(
            onTap: () => {Navigator.pop(context)},
            child: Container(
              width: 200,
              height: 50,
              child: Text('Go Back'),
            ),
          )),
        ));
  }
}
